﻿
@{
    ViewData["Title"] = "Form";
    Layout = "~/Areas/Admin/Views/Shared/_FormLayout.cshtml";
    @model SysPage;
}

<form class="layui-form">
    <input type="hidden" id="SysPageId" name="SysPageId"
           autocomplete="off" class="layui-input" value="@Model.SysPageId">
    <div class="layui-form-item">
        <label for="SysPageName" class="layui-form-label">
            <span class="we-red">*</span>页面名称
        </label>
        <div class="layui-input-inline">
            <input type="text" id="SysPageName" name="SysPageName" required="" value="@Model.SysPageName" lay-verify="required"
                   autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">
            <span class="we-red">*</span>请填写页面名称
        </div>
    </div>

    <div class="layui-form-item">
        <label for="SysPageNum" class="layui-form-label">
            <span class="we-red">*</span>页面编号
        </label>
        <div class="layui-input-inline">
            <input type="text" id="SysPageNum" name="SysPageNum" value="@Model.SysPageNum"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="SysPageUrl" class="layui-form-label">
            <span class="we-red">*</span>页面地址
        </label>
        <div class="layui-input-inline">
            <input type="text" id="SysPageUrl" name="SysPageUrl" value="@Model.SysPageUrl"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="SysPageImg" class="layui-form-label">
            <span class="we-red">*</span>页面图标
        </label>
        <div class="layui-input-inline">
            <input type="text" id="SysPageImg" name="SysPageImg" value="@Model.SysPageImg"
                   autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label for="Sort" class="layui-form-label">
            父级页面
        </label>
        <div class="layui-input-inline">
            <select id="SysPageParent" name="SysPageParent" class="layui-input">
                <option value="">无</option>
                @foreach (var item in ViewBag.SysPageParentSelect)
                {
                    if (Model.SysPageParent == item.Key)
                    {
                        <option selected value="@item.Key">@item.Value</option>
                    }
                    else
                    {
                        <option value="@item.Key">@item.Value</option>
                    }
                }
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label for="Sort" class="layui-form-label">
            排序
        </label>
        <div class="layui-input-inline">
            <input type="text" id="Sort" name="Sort" value="@Model.Sort"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label for="Remark" class="layui-form-label">
            备注
        </label>
        <div class="layui-input-inline">
            <input type="text" id="Remark" name="Remark" value="@Model.Remark"
                   autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><span class="we-red">*</span>状态</label>
        <div class="layui-input-block">
            <input type="checkbox" name="Status" lay-skin="primary" title="启用" value="1" @Html.Raw(Model.Status == 1 ? "checked" : "")>
        </div>
    </div>
    <div class="layui-form-item">
        <label for="L_repass" class="layui-form-label"></label>
        <button class="layui-btn" lay-filter="add" lay-submit="">@Html.Raw(ViewBag.isCreate ? "添加" : "更新")</button>
    </div>
</form>
@section Scripts{
    <script type="text/javascript">
        _ContralPath = "/Admin/SysPage/";
        layui.use(['form', 'layer', 'admin','jquery'], function () {
            var form = layui.form,
                admin = layui.admin,
                layer = layui.layer,
                $  =layui.jquery;
            form.render();
            //自定义验证规则
            form.verify({
               
            });

            //监听提交
            form.on('submit(add)', function (data) {
                //发异步，把数据提交给后台
                $.post(_ContralPath + _SavePath, data.field, function (res) {
                    if (res.success) {
                        layer.confirm('操作成功，是否关闭当前窗口?', function () {
                            parent.reloadData();//刷新数据
                            parent.colseForm(window.name);//关闭窗口
                        });
                    } else {
                        layer.msg("操作失败," + res.msg);
                    }
                }, "json");
               
                return false;
            });
        });
    </script>
}

